package com.ct.lotterysystem2.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ct.lotterysystem2.dao.dataobject.PrizeDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PrizeMapper extends BaseMapper<PrizeDO> {

    @Select("select count(1) from prize")
    int count();

    @Select("select * from prize order by id desc limit #{offset}, #{pageSize}")
    List<PrizeDO> selectPrizeList(@Param("offset") Integer offset,
                                  @Param("pageSize") Integer pageSize);

    @Select("<script>" +
            " select * from prize" +
            " where id in" +
            " <foreach collection='items' item='item' open='(' close=')' sparator=','>" +
            " #{item}" +
            " </foreach>" +
            " </script>")
    List<PrizeDO> batchSelectByIds(@Param("items") List<Long> prizeIds);
}
